/*
 * qiangungun.com Inc.
 * Copyright (c) 2014 All Rights Reserved.
 */package com.qiangungun.xts.common.dal.ibatis;import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;import com.qiangungun.xts.common.dal.daointerface.BusinessActivityDAO;// auto generated importsimport java.util.List;import org.springframework.dao.DataAccessException;import java.util.Date;import java.util.Map;import java.util.HashMap;import com.qiangungun.xts.common.dal.dataobject.BusinessActivityDO;/** * An ibatis based implementation of dao interface <tt>com.qiangungun.xts.common.dal.daointerface.BusinessActivityDAO</tt>. * * This file is generated by <tt>financenet-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>iwallet</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/business_activity.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>financenet-dalgen</tt> 
 * to generate this file.
 *
 */@SuppressWarnings({"unchecked","deprecation"})public class IbatisBusinessActivityDAO extends SqlMapClientDaoSupport implements BusinessActivityDAO {	/**
	 *  Query DB table <tt>business_activity</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, activity_id, state, propagation, context, gmt_create, gmt_modified from business_activity where (state = 'I')</tt>
	 *
	 *	@param beginDate
	 *	@param endDate
	 *	@return List<BusinessActivityDO>
	 *	@throws DataAccessException
	 */	 
    public List<BusinessActivityDO> getInitActivitiesByTime(Date beginDate, Date endDate) throws DataAccessException {
        Map<String,Object> param = new HashMap<String,Object>();

        param.put("beginDate", beginDate);
        param.put("endDate", endDate);

        return getSqlMapClientTemplate().queryForList("MS-BUSINESS-ACTIVITY-GET-INIT-ACTIVITIES-BY-TIME", param);

    }		/**
	 *  Insert one <tt>BusinessActivityDO</tt> object to DB table <tt>business_activity</tt>, return primary key
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into business_activity(activity_id,state,propagation,context,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?)</tt>
	 *
	 *	@param businessActivity
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int store(BusinessActivityDO businessActivity) throws DataAccessException {
    	if (businessActivity == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-BUSINESS-ACTIVITY-STORE", businessActivity);

        return businessActivity.getId();
    }		/**
	 *  Update DB table <tt>business_activity</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update business_activity set state=? where (activity_id = ?)</tt>
	 *
	 *	@param state
	 *	@param activityId
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateStatus(String state, String activityId) throws DataAccessException {
        Map<String,Object> param = new HashMap<String,Object>();

        param.put("state", state);
        param.put("activityId", activityId);

        return getSqlMapClientTemplate().update("MS-BUSINESS-ACTIVITY-UPDATE-STATUS", param);
    }	}	